﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace P2PLib.Client.Command
{
    public class CCFileStaratPositionCommand:CCCommandBase
    {
        private long startPostion;

        public long StartPostion
        {
            set
            {
                this.startPostion = value;
            }
            get
            {
                return this.startPostion;
            }
        }

        public CCFileStaratPositionCommand()
            : base(CCCommandType.FileStartPosition)
        {
            this.startPostion = 0;
        }

        public CCFileStaratPositionCommand(long pos)
            : base(CCCommandType.FileStartPosition)
        {
            this.startPostion = pos;
        }

        public override void ReadFromStream(System.IO.Stream stream)
        {
            byte[] buffer = new byte[8];
            stream.Read(buffer,0,8);
            this.startPostion = BitConverter.ToInt64(buffer,0);
        }

        public override void WriteToStream(System.IO.Stream stream)
        {
            byte[] buffer = BitConverter.GetBytes(this.startPostion);
            stream.Write(buffer,0,buffer.Length);
        }
    }
}
